import Vue from 'vue'
import Vuex from 'vuex'
import {getdata} from '../api/index'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list:[],
    item:[]
  },
  mutations: {
    GET_LIST(state,payload){
      state.list=payload
      // console.log(payload)
    },
    GET_DETAIL(state,payload){
    state.item=state.list.find(item=>item.id===payload)
      console.log(state.item)
    }
  },
  actions: {
   async SET_LIST({commit}){
      const resp=await getdata()
      commit('GET_LIST',resp.data.data)
    }
  },
  modules: {
  }
})
